package com.cy.核心编程.thead.basic.sleep;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * sleep线程睡眠
 */
public class MyThead extends Thread{
    @Override
    public void run() {
        while (true){
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            System.out.println(sdf.format(new Date()));
            try {
                Thread.sleep(1000);//1000毫秒 = 1秒
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
    public static void main(String[] args) {
        MyThead mt = new MyThead();
        mt.start();
    }
}
